import upload from '@dfeidao/atom-mobile/fs/upload';
import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import local_get from '@dfeidao/atom-mobile/local/get';
import toast from '@dfeidao/atom-mobile/msgbox/toast';

export default async function a003(fd: IFeidaoAiMobile) {
	// "/data/user/0/com.feidaotest/filesimage-c2cde946-d8a0-4931-9721-ed75e28df42f1370751877.jpg"
	const f = local_get(fd, 'f') as string;
	// const path = DocumentDirectoryPath + '/img.jpeg';
	// const img = await r(f, 'base64');
	// await write(path, img, 'base64');
	// console.log('*********************************', path);
	const files = [
		{
			name: 'feidao',
			filename: 'img.jpeg',
			filepath: f,
			filetype: 'image/jpeg'
		}
	];
	const res = await upload(fd, {
		files,
		toUrl: 'http://192.168.40.196/fsweb/upload?productid=teach_sys',
		method: 'POST',
		headers: {
			'Accept': 'application/json'
		}
	}, 'a004', 'a005');
	console.log(res);
	if (res.code === 1) {
		toast({
			type: 'success',
			text: '上传成功',
			position: 'bottom'
		});
	}
}
